<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
	<meta charset="UTF-8">
	<title>更换微信号</title>
	<meta name="description" content="">
	<meta name="keywords" content="">
	<meta name="viewport" content="initial-scale=1, width=device-width, maximum-scale=1, user-scalable=no">
	<meta name="format-detection" content="telephone=no,email=no,adress=no" />
	<meta name="apple-mobile-web-app-capable" content="yes" />  
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<link rel="stylesheet" href="{THEME_PATH}styles/swiper.min.css">
	<link rel="stylesheet" href="{THEME_PATH}styles/reset.css">
	<link rel="stylesheet" href="{THEME_PATH}styles/common.css">
	<link rel="stylesheet" href="{THEME_PATH}styles/style.css">
	<script src="{THEME_PATH}js/jquery-1.8.3.min.js"></script>
	<script src="{THEME_PATH}js/swiper.min.js"></script>
	<script src="/statics/js/layer/layer.js"></script>
</head>
<body>
	<!-- S header -->
	<header class="alliance_details_header">
		<a href="/index.php?m=user&c=home&a=personal_info" class="headerL iconfont">&#xe69f;</a>
		<h1>更换微信号</h1>
	</header>
	<!-- E header -->
	
	<ul class="change_num_box">
		<li class="flex">
			<label class="label label-zfb">微信号</label>
			<div class="flex-1 input_box"><input type="text" name="wx_account" placeholder="请输入新的微信号" value="<?php echo $user_info['wx_account'] ?$user_info['wx_account'] : ''; ?>"></div>
		</li>
	</ul>

	<dl class="uploading_box userImg" id="header_file">
		<dt>上传微信二维码</dt>
		<dd>
			<a href="javascript:;" class="inline_block"><img src="<?php echo $user_info['wx_qr_code'] ? $user_info['wx_qr_code'] : THEME_PATH.'images/uploading.png'; ?>" alt="" width="" class="uploading_img"></a>
		</dd>
		<input type="file" id="file_up" name="上传" style="display:none;"/>
	</dl>

	<a href="javascript:;" class="btn">提交</a>
</body>
<link href="/statics/js/webuploader/webuploader.css" rel="stylesheet" />
<script src="/statics/js/webuploader/webuploader.js" type="text/javascript"></script>
<script type="text/javascript">
    var uploader = WebUploader.create({
        auto:true,
        fileVal:'upfile',
        // swf文件路径
        swf: '/statics/js/webuploader/webuploader.swf',
        // 文件接收服务端。
        server: "/index.php?m=attachment&c=upload&a=swfupload",
        // 选择文件的按钮。可选
        formData:{
            "module":"",
            "catid":"",
            "userid":"1",
            "dosubmit":"1",
            "thumb_width":"0",
            "thumb_height":"0",
            "watermark_enable":"1",
            "filetype_post":"jpg|jpeg|gif|bmp|png",
            "swf_auth_key":"57a39f6f7415ec2cdd2b8afd77b57c3f",
            "isadmin":"1"
        },
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: {
            id: '#header_file',
            multiple:false
        },
        accept:{
            title: '图片文件',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/*'
        },
        thumb:{
            width: '110',
            height: '110',
        },
        chunked: false,
        chunkSize:1000000,
        // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
        resize: false
    });
    uploader.onUploadSuccess = function( file, response ) {
        var pickid = this.options.pick.id;
        var data = response._raw;
        var arr = data.split(',');
        if(response.url.length > 0) {
            $(pickid).find('img').attr('src', response.url);
            $(pickid).find('input[type=hidden]').eq(0).attr('value', response.url);
        }
        $.post(
			"/index.php?m=user&c=upload&a=upload_user_avatar_wap1",
			{img_url : response.url},
			function(data){
				console.log(11111);
				if (data.status == 1) {
					location.reload();
				}else{
					hd_alert(data.info);
					if (data.url) {
						location.href = data.url;
						return false;
					}
					location.reload();
				}
       	 	},'json'
		)
    }
    uploader.onUploadError = function(file, reason) {
        hd_alert('文件上传错误：' + reason);
    }
</script>
<script>
$('.btn').click(function(){
	var wx_account = $("input[name='wx_account']").val();
	if(!wx_account){
		layer.msg('请填写微信账号');
		return;
	}
	$.ajax({
		url:"/index.php/?m=user&c=home&a=change_wx",
		type:'post',
		data:{
			wx_account:wx_account,
		},
		dataType:'json',
		success:function(data){
			if(data.status ==0){
				layer.msg(data.info);
			}else{
				layer.msg(data.info);
				setTimeout(function(){
							location.reload();
						},1000);
				// location.href = "/index.php?m=user&c=home&a=index";
				return;
			}
		}
	});
})
</script>
</html>